package com.muzinan.template.controller;

import com.muzinan.template.base.result.ResponseResult;
import com.muzinan.template.strategy.context.UploadStrategyContext;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: MuZiNan
 * @createDate: 2022/11/25
 * @description: 上传测试Controller
 * @version： 1.0
 */
@RestController
@RequiredArgsConstructor
public class UploadController {

    private final UploadStrategyContext uploadStrategyContext;

    @PostMapping("/upload")
    public ResponseResult<?> upload(MultipartFile file) {
        return ResponseResult.success("文件上传成功！",uploadStrategyContext.executeUploadStrategy(file,"blog/avatar","localUploadServiceImpl"));
    }
}
